package 扑克牌;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Gao zhao xu
 * Date: 2023-09-16
 * Time: 16:20
 */
public class test {
    public static final String[] SUITS= {"♥","♠","♣","♦"};
    public static List<Card> buyCard(){
        List<Card> cards = new ArrayList<>();
        for(int i = 0; i < SUITS.length;i++){
            for (int j = 1; j <= 13; j++){
                Card card = new Card(SUITS[i], j);
                cards.add(card);
            }
        }
        return cards;
    }
    public static List<Card> shuffle(List<Card> cards){
        Random random = new Random();
        for (int i = 0;  i < cards.size() - 1; i++){
            int j = random.nextInt(i + 1,cards.size());
            Card card = cards.get(i);
            cards.set(i, cards.get(j));
            cards.set(j, card);
        }
        return cards;
    }
    public static void main(String[] args) {
        List<Card> cards = buyCard();
        System.out.println(cards);
        cards = shuffle(cards);
        System.out.println("洗牌：");
        System.out.println(cards);
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        List<List<Card>> hands = new ArrayList<>();
        hands.add(hand1);
        hands.add(hand2);
        hands.add(hand3);
        for(int i = 0; i < 5; i++){
            for (int j = 0 ; j < 3; j++){
                Card card = cards.remove(0);
                hands.get(j).add(card);
            }
        }
        System.out.println("第一个人牌：");
        System.out.println(hand1);
        System.out.println("第二个人牌：");
        System.out.println(hand2);
        System.out.println("第三个人牌：");
        System.out.println(hand3);
        System.out.println("剩余的牌：");
        System.out.println(cards);
    }
}
